﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Weazel.Math;

#endregion

namespace Weazel.Math.Test
{
  [TestClass]
  public class TestToInt
  {
    [TestMethod]
    public void TestUnsigned3Bit()
    {
      Integer a = new Integer(3, "6", false);
      Assert.AreEqual((int)6, a.ToInt());
    }

    [TestMethod]
    public void TestSigned3Bit()
    {
      // 6 = 0x110 = -2
      Integer a = new Integer(3, "6", true);
      Assert.AreEqual((int)-2, a.ToInt());
    }

    [TestMethod]
    public void TestUnsigned8Bit()
    {
      Integer a = new Integer(8, "0xFF", false);
      Assert.AreEqual((int)0xFF, a.ToInt());
    }

    [TestMethod]
    public void TestToSigned8Bit()
    {
      Integer a = new Integer(8, "0xFF", true);
      Assert.AreEqual((int)-1, a.ToInt());
    }

    [TestMethod]
    public void TestToUnsignedOverflow_1()
    {
      Integer a = new Integer(64, "0xFFFFFFFFFFFFFFFF", false);
      Assert.AreEqual((int)-1, a.ToInt());
    }

    [TestMethod]
    public void TestToSignedOverflow_1()
    {
      Integer a = new Integer(64, "0xFFFFFFFFFFFFFFFF", true);
      Assert.AreEqual((int)-1, a.ToInt());
    }
  }
}
